<?php

/**
 * This is the model class for table "SKU".
 *
 * The followings are the available columns in table 'SKU':
 * @property integer $ID
 * @property string $SKU
 * @property string $ASIN
 * @property string $ProductNumber
 * @property integer $ProductID
 * @property string $OrigProductNo
 * @property integer $Quantity
 * @property string $Package
 * @property string $Title
 * @property string $Used
 * @property string $UsedDate
 * @property string $FollowListing
 * @property string $Active
 * @property string $Comment
 * @property string $FBA
 * @property string $PA
 * @property integer $SalesTotal
 * @property integer $SkimTotal
 * @property string $Remark
 */
class SKU extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return SKU the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'SKU';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('ID', 'required'),
			array('ID, ProductID, Quantity, SalesTotal, SkimTotal', 'numerical', 'integerOnly'=>true),
			array('SKU, ASIN, Package, Used, UsedDate, FollowListing, Active, FBA, PA', 'length', 'max'=>50),
			array('ProductNumber, OrigProductNo, Title', 'length', 'max'=>200),
			array('Comment, Remark', 'length', 'max'=>1073741823),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID, SKU, ASIN, ProductNumber, ProductID, OrigProductNo, Quantity, Package, Title, Used, UsedDate, FollowListing, Active, Comment, FBA, PA, SalesTotal, SkimTotal, Remark', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID' => 'ID',
			'SKU' => 'Sku',
			'ASIN' => 'Asin',
			'ProductNumber' => 'Product Number',
			'ProductID' => 'Product',
			'OrigProductNo' => 'Orig Product No',
			'Quantity' => 'Quantity',
			'Package' => 'Package',
			'Title' => 'Title',
			'Used' => 'Used',
			'UsedDate' => 'Used Date',
			'FollowListing' => 'Follow Listing',
			'Active' => 'Active',
			'Comment' => 'Comment',
			'FBA' => 'Fba',
			'PA' => 'Pa',
			'SalesTotal' => 'Sales Total',
			'SkimTotal' => 'Skim Total',
			'Remark' => 'Remark',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID',$this->ID);
		$criteria->compare('SKU',$this->SKU,true);
		$criteria->compare('ASIN',$this->ASIN,true);
		$criteria->compare('ProductNumber',$this->ProductNumber,true);
		$criteria->compare('ProductID',$this->ProductID);
		$criteria->compare('OrigProductNo',$this->OrigProductNo,true);
		$criteria->compare('Quantity',$this->Quantity);
		$criteria->compare('Package',$this->Package,true);
		$criteria->compare('Title',$this->Title,true);
		$criteria->compare('Used',$this->Used,true);
		$criteria->compare('UsedDate',$this->UsedDate,true);
		$criteria->compare('FollowListing',$this->FollowListing,true);
		$criteria->compare('Active',$this->Active,true);
		$criteria->compare('Comment',$this->Comment,true);
		$criteria->compare('FBA',$this->FBA,true);
		$criteria->compare('PA',$this->PA,true);
		$criteria->compare('SalesTotal',$this->SalesTotal);
		$criteria->compare('SkimTotal',$this->SkimTotal);
		$criteria->compare('Remark',$this->Remark,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}